let app = document.querySelector('#container>.head>b:nth-of-type(2)')
let uu = document.querySelector('.xiang')
let foot = document.querySelector('.footer')
let li1 = document.querySelector('.uu>li:nth-of-type(1)')
let li2 = document.querySelector('.uu>li:nth-of-type(2)')
let li3 = document.querySelector('.uu>li:nth-of-type(3)')
let li4 = document.querySelector('.uu>li:nth-of-type(4)')
let li5 = document.querySelector('.uu>li:nth-of-type(5)')
let li6 = document.querySelector('.uu>li:nth-of-type(6)')
let li7 = document.querySelector('.uu>li:nth-of-type(7)')
let li9 = document.querySelector('.uu>li:nth-of-type(9)')
let li10 = document.querySelector('.uu>li:nth-of-type(10)')
let li11 = document.querySelector('.uu>li:nth-of-type(11)')
let li12 = document.querySelector('.uu>li:nth-of-type(12)')
fetch('http://chst.vip:1234/api/getmoneyctrl')
    .then(body => body.json())
    .then(res => {
        console.log(res)
        render(res.result, uu)
    })
function render(data, el) {
    // console.log(data,el)
    let domStr = ''
    data.forEach(item => {
        // let li = document.createElement('li')
        let regExp = /(?<=imgurl=)[^'"]*/
        let result = item.productImg2.match(regExp)
        result = result[0]
        // console.log(item)

        domStr += `<li productid=${item.productId}><img src="${result}" alt=""><h3>${item.productName}<span>${item.productPinkage}</span></h3>
        <span>${item.productComCount}</span>
        <span>${item.productFrom}</span></li>
        `
        el.innerHTML = domStr
        // el.appendChild(li)
    })
}
uu.onclick = function (e) {
    console.log(e.target)
    if (e.target.localName == 'li') {
        let _this = e.target
        let id = _this.getAttribute('productid')
        console.log(id);
        location.href = "./../html/indexxiang.html?productid=" + id

        id = Number(id)
        console.log(id)
    } 
}
// app.onclick = function () {
//     alert('辣鸡软件，拒绝下载')
// }
li1.onclick = function () {
    location.href = "./../html/bijiaxiang.html"
}
li2.onclick = function () {
    location.href = "./../html/lanjiazai.html"
}
li3.onclick = function () {
    location.href = "./../html/guonei.html"
}
li4.onclick = function () {
    location.href = "./../html/baicaijia.html"
}
li5.onclick = function () {
    location.href = "./../html/haitao.html"
}
li6.onclick = function () {
    location.href = "./../html/youhui.html"
}
li7.onclick = function () {
    location.href = "./../html/bijiaxiang.html"
}
li9.onclick = function () {
    location.href = "./../html/coudan.html"
}
li10.onclick = function () {
    location.href = "./../html/bijiaxiang.html"
}
li11.onclick = function () {
    location.href = "./../html/daohang.html"
}
li12.onclick = function () {
    location.href = "./../html/pinpai.html"
}
foot.onclick = function () {
    let scrollTop = document.documentElement.scrollTop
    // console.log(scrollTop)
    document.documentElement.scrollTop = 0;
}
//更多
$('.more').click(function () {
    $('.active').slideToggle(200)
})

